package com.springboot.orderno.common;

import lombok.Data;
import java.io.Serializable;
import java.util.UUID;

@Data
public class ResultVO<T> implements Serializable {
    private static final long serialVersionUID = 1L;

    private int code;

    private String msg = "操作成功";

    private T data;

    private String logCode;

    public void resultFail(String msg, int code) {
        this.msg = msg;
        this.data = null;
        this.code = code;
        this.logCode = UUID.randomUUID().toString();
    }

    public void resultFail(String msg) {
        this.msg = msg;
        this.data = null;
        this.code = 1;
        this.logCode = UUID.randomUUID().toString();
    }

    public void resultSuccess(T obj) {
        this.data = obj;
        this.code = 0;
    }

    public void resultSuccess(String msg, T obj) {
        this.msg = msg;
        this.data = obj;
        this.code = 0;
    }

    public void resultSuccess(String msg, int code) {
        this.msg = msg;
        this.code = code;
        this.logCode = UUID.randomUUID().toString();
    }

    public boolean returnSuccess() {
        return this.getCode() == 200;
    }

    @Override
    public boolean equals(Object o) {
        if (o == this) {
            return true;
        } else if (!(o instanceof ResultVO)) {
            return false;
        } else {
            ResultVO<?> other = (ResultVO) o;
            if (!other.canEqual(this)) {
                return false;
            } else if (this.getCode() != other.getCode()) {
                return false;
            } else {
                label49:
                {
                    Object this$msg = this.getMsg();
                    Object other$msg = other.getMsg();
                    if (this$msg == null) {
                        if (other$msg == null) {
                            break label49;
                        }
                    } else if (this$msg.equals(other$msg)) {
                        break label49;
                    }

                    return false;
                }

                Object this$data = this.getData();
                Object other$data = other.getData();
                if (this$data == null) {
                    if (other$data != null) {
                        return false;
                    }
                } else if (!this$data.equals(other$data)) {
                    return false;
                }

                Object this$logCode = this.getLogCode();
                Object other$logCode = other.getLogCode();
                if (this$logCode == null) {
                    if (other$logCode != null) {
                        return false;
                    }
                } else if (!this$logCode.equals(other$logCode)) {
                    return false;
                }

                return true;
            }
        }
    }

    protected boolean canEqual(Object other) {
        return other instanceof ResultVO;
    }

    @Override
    public int hashCode() {
        int result = 1;
        result = result * 59 + this.getCode();
        Object $msg = this.getMsg();
        result = result * 59 + ($msg == null ? 43 : $msg.hashCode());
        Object $data = this.getData();
        result = result * 59 + ($data == null ? 43 : $data.hashCode());
        Object $logCode = this.getLogCode();
        result = result * 59 + ($logCode == null ? 43 : $logCode.hashCode());
        return result;
    }

    @Override
    public String toString() {
        return "ResultVO(code=" + this.getCode() + ", msg=" + this.getMsg() + ", data=" + this.getData() + ", logCode=" + this.getLogCode() + ")";
    }
}
